//注册
const fs=require('fs')
let user={username:"xm31",password:"333"}

let result= fs.readFileSync('persons.json','utf8')
//换成数组
result = JSON.parse( result )

let a = result.some(item=> 
    item.username == user.username && item.password == user.password
)
if(!a)
{
    result.push(user)
    //换成字符串
    fs.writeFileSync('persons.json',JSON.stringify(result))
    console.log('注册成功')
}
else{
      console.log('登录成功' )
}
// console.log(result)